package com.linxin.ai_automates_periodontal_treatment_system.config;

// AppConfig.java

import com.linxin.ai_automates_periodontal_treatment_system.interceptor.TokenInterceptor;
import com.linxin.ai_automates_periodontal_treatment_system.service.DoctorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
@ComponentScan("com.linxin.ai_automates_periodontal_treatment_system.service")
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private DoctorService doctorService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册Token拦截器
        log.info("注册Token拦截器");
        // 添加Token拦截器, 所有请求都需要经过Token拦截器
        registry.addInterceptor(new TokenInterceptor(doctorService)).addPathPatterns("/**");
    }
}

